package com.lc.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lc.bean.Supplier;
import com.lc.mapper.SupplierMapper;
import com.lc.service.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SupplierServiceImpl implements SupplierService {

    @Autowired
    SupplierMapper supplierMapper;

    @Override
    public List<Supplier> findAll() {
        return supplierMapper.findAll();
    }

    @Override
    public void save(Supplier supplier) {
        supplierMapper.save(supplier);
    }

    @Override
    public void del(Integer uuid) {
        supplierMapper.del(uuid);
    }

    @Override
    public Supplier findById(Integer uuid) {
        return supplierMapper.findById(uuid);
    }

    @Override
    public void update(Supplier supplier) {
        supplierMapper.update(supplier);
    }

    @Override
    public PageInfo<Supplier> findByConditions(Supplier supplier, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Supplier> sups = supplierMapper.findByConditions(supplier);

        PageInfo<Supplier> pageInfo = new PageInfo<>(sups);

        return pageInfo;
    }

    @Override
    public List<Supplier> selectOptionItems() {
        return supplierMapper.selectOptionItems();
    }
}
